import { deleteByPrimaryKeyForProGroup, selectByPrimaryKeyForProGroup, insertForProGroup, updateForProGroup, deleteByMapForProGroup,updateByMapForProGroup, getOneForProGroup,getAllForProGroup,queryPageForProGroup, countForProGroup, insertBatchForProGroup, deleteBatchForProGroup,updateBatchForProGroup } from '@/services/system/api_progroup';

export default {
    namespace: 'progroup',

    state: {
        data: {
            list: [],
            pagination: {},
        },
    },

    effects: {
            *delete_by_primarykey_for_progroup({ payload }, { call, put }) {
                const response = yield call(deleteByPrimaryKeyForProGroup, payload);
                yield put({
                    type: 'deleteByPrimaryKeyForProGroup',
                    payload: response,
                });

                const responsedata = yield call(queryPageForProGroup, {});
                yield put({
                type: 'queryPageForProGroup',
                payload: responsedata,
                });


            },
            *select_by_primarykey_for_progroup({ payload, callback }, { call, put }) {
                const response = yield call(selectByPrimaryKeyForProGroup, payload);
                yield put({
                    type: 'selectByPrimaryKeyForProGroup',
                    payload: response,
                });

                if (callback) callback();
            },
            *insert_for_progroup({ payload, callback }, { call, put }) {
                const response = yield call(insertForProGroup, payload);
                yield put({
                    type: 'insertForProGroup',
                    payload: response,
                });

                const responsedata = yield call(queryPageForProGroup, {});
                yield put({
                type: 'queryPageForProGroup',
                payload: responsedata,
                });

                if (callback) callback();
            },
            *update_for_progroup({ payload, callback }, { call, put }) {
                const response = yield call(updateForProGroup, payload);
                yield put({
                    type: 'updateForProGroup',
                    payload: response,
                });


                const responsedata = yield call(queryPageForProGroup, {});
                yield put({
                type: 'queryPageForProGroup',
                payload: responsedata,
                });

                if (callback) callback();
            },
            *delete_by_map_for_progroup({ payload, callback }, { call, put }) {
                const response = yield call(deleteByMapForProGroup, payload);
                yield put({
                    type: 'deleteByMapForProGroup',
                    payload: response,
                });


                const responsedata = yield call(queryPageForProGroup, {});
                yield put({
                type: 'queryPageForProGroup',
                payload: responsedata,
                });

                if (callback) callback();
            },
            *update_by_map_for_progroup({ payload, callback }, { call, put }) {
                const response = yield call(updateByMapForProGroup, payload);
                yield put({
                    type: 'updateByMapForProGroup',
                    payload: response,
                });


                const responsedata = yield call(queryPageForProGroup, {});
                yield put({
                type: 'queryPageForProGroup',
                payload: responsedata,
                });

                if (callback) callback();
            },
            *get_one_for_progroup({ payload, callback }, { call, put }) {
                const response = yield call(getOneForProGroup, payload);
                yield put({
                    type: 'getOneForProGroup',
                    payload: response,
                });

                if (callback) callback();
            },
            *get_all_for_progroup({ payload, callback }, { call, put }) {
                const response = yield call(getAllForProGroup, payload);
                yield put({
                    type: 'getAllForProGroup',
                    payload: response,
                });

                if (callback) callback();
            },
            *query_page_for_progroup({ payload, callback }, { call, put }) {
                const response = yield call(queryPageForProGroup, payload);
                yield put({
                    type: 'queryPageForProGroup',
                    payload: response,
                });

                if (callback) callback();
            },
            *count_for_progroup({ payload, callback }, { call, put }) {
                const response = yield call(countForProGroup, payload);
                yield put({
                    type: 'countForProGroup',
                    payload: response,
                });

                if (callback) callback();
            },
            *insert_batch_for_progroup({ payload, callback }, { call, put }) {
                const response = yield call(insertBatchForProGroup, payload);
                yield put({
                    type: 'insertBatchForProGroup',
                    payload: response,
                });


                const responsedata = yield call(queryPageForProGroup, {});
                yield put({
                type: 'queryPageForProGroup',
                payload: responsedata,
                });


                if (callback) callback();
            },
            *delete_batch_for_progroup({ payload, callback }, { call, put }) {
                const response = yield call(deleteBatchForProGroup, payload);
                yield put({
                    type: 'deleteBatchForProGroup',
                    payload: response,
                });

                const responsedata = yield call(queryPageForProGroup, {});
                yield put({
                type: 'queryPageForProGroup',
                payload: responsedata,
                });

                if (callback) callback();
            },
            *update_batch_for_progroup({ payload, callback }, { call, put }) {
                const response = yield call(updateBatchForProGroup, payload);
                yield put({
                    type: 'updateBatchForProGroup',
                    payload: response,
                });

                const responsedata = yield call(queryPageForProGroup, {});
                yield put({
                type: 'queryPageForProGroup',
                payload: responsedata,
                });

                if (callback) callback();
            },
            },

    reducers: {
        deleteByPrimaryKeyForProGroup(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        selectByPrimaryKeyForProGroup(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        insertForProGroup(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        updateForProGroup(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        deleteByMapForProGroup(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        updateByMapForProGroup(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        getOneForProGroup(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        getAllForProGroup(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        queryPageForProGroup(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        countForProGroup(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        insertBatchForProGroup(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        deleteBatchForProGroup(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        updateBatchForProGroup(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
    },
};
